﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Reflection;
using System.IO;

namespace WebDavTest
{
    public class Reset
    {
        public static String UnitsTestRepository;
 
        public static bool ResetRepository()
        {
            WebDav.WebDav webdav = new WebDav.WebDav(null, null);
            HttpStatusCode status = new HttpStatusCode();
            DateTime now = DateTime.Now;

            UnitsTestRepository = "http://netrepo.free.fr/webdav_server.php/UnitsTest/";
            UnitsTestRepository += now.ToString().Replace(' ', '_').Replace('/', '-').Replace(':', '-') + "/";
            //webdav.Delete(UnitsTestRepository, ref status);
            webdav.CreateDirectory(UnitsTestRepository, ref status);
            webdav.CreateDirectory(UnitsTestRepository + "test", ref status);
            webdav.UploadFile(UnitsTestRepository + Path.GetFileName(Assembly.GetExecutingAssembly().Location), Path.GetFileName(Assembly.GetExecutingAssembly().Location), ref status);
            //webdav.UploadFile("http://netrepo.sourceforge.net/webdav_server.php/toto.txt", @"C:\Documents and Settings\Math\Desktop\bin\nunit.framework.dll", ref status);

            return true;
        }
    }
}
